package com.tao.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.tao.dao.UserDao;
import com.tao.entity.User;
import com.tao.service.LoginService;

/**
 * 登陆 Model 的实现类
 * @author Administrator
 *
 */

@Service
public class LoginServiceImpl implements LoginService{

	@Autowired
	private UserDao userDao;
	 
	@Override
	public int Login(User user) {
		// 检测用户名
				User u=userDao.findUserByPhone(user.getPhone());
				if(u==null){
					return 1;  //用户名不对
				}else {
					//判断密码
					if(u.getPwd().equals(user.getPwd())){
						user.setId(u.getId());
						user.setPhone(u.getPhone());
						user.setPwd(u.getPwd());
						return 3;
					}else{
						return 2;  //密码错误
					}
				}
			}

		}
